package com.qf.day12.generic;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Random;

/**
 * 再创建集合对象时，要使用泛型参数
 */
public class GenericDemo02 {

    public static void main(String[] args) {
        Collection<Student> students = new ArrayList<Student>();
        Random random = new Random();
        students.add(new Student("万超岩",random.nextDouble()*100));
        students.add(new Student("臧家彤",random.nextDouble()*100));

        // 编译报错
//        students.add(new Teacher("旭哥",random.nextDouble()*1000));
//        students.add("哈哈");

        for (Student student : students) {
            System.out.println(student.getScore());
        }

    }

}
